<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
    {include file="base/header" /}
    <div style="width: 600px;margin: 0 auto">
    <form class="layui-form" action="">
        <input type="hidden" name="id" value="{$id}"/>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >产品名称</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" readonly value="{$result.pname}" name="pname" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >订单号</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" readonly value="{$result.ordernumber}" name="ordernumber" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >下单时间</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" readonly value="{$result.date}" name="date" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width:150px;" >描述</label>
            <div class="layui-input-block">
                <textarea name="address" style="width: 400px" readonly placeholder="请输入内容" class="layui-textarea">{$result.describe}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >类别</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" readonly value="{$result.category}" name="category" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div><div class="layui-form-item">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width:150px;" >产品介绍</label>
            <div class="layui-input-block">
                <textarea name="introduce" style="width: 400px" readonly  placeholder="请输入内容" class="layui-textarea">{$result.introduce}</textarea>
            </div>
        </div>
       <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >购买数量(个)</label>
            <div class="layui-input-block">
                {if $status == 1 or $status == 2}
                <input type="text"  style="width: 400px"  value="{$result.number}"  name="number" required  lay-verify="required"  autocomplete="off" class="layui-input">
                {else/}
                <input type="text"  style="width: 400px"  value="{$result.number}" readonly name="number" required  lay-verify="required"  autocomplete="off" class="layui-input">
                {/if}
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >进货价格(元)</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" name="purchaseprice" readonly  value="{$result.purchaseprice}" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >售价(元)</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" name="retailprice" readonly  required value="{$result.retailprice}" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >合计(元)</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" name="total" readonly  required value="{$result.total}" lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >合作模式</label>
            <div class="layui-input-block">
                {if $result.cooperation == 1}
                <input type="text" style="width: 400px" value="进货价采购" name="cooperation" readonly required  lay-verify="required"  autocomplete="off" class="layui-input">
                {else/}
                <input type="text" style="width: 400px" value="少量货物月结" name="cooperation" readonly required  lay-verify="required"  autocomplete="off" class="layui-input">
                {/if}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >线下店铺联系人</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" name="linkman" readonly value="{$result.linkman}" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width:150px;" >联系电话</label>
            <div class="layui-input-block">
                <input type="text" style="width: 400px" name="telephone" readonly value="{$result.telephone}" required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width:150px;" >线下店地址</label>
            <div class="layui-input-block">
                <textarea name="address" style="width: 400px" readonly placeholder="请输入内容" class="layui-textarea">{$result.address}</textarea>
            </div>
        </div>
        {if !empty($result.images)}
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width:150px;" >支付凭证</label>
            <div class="layui-input-block">
                <img src="__ROOT__\{$result.images}">
            </div>
        </div>
        {/if}
    </form>

    </div>
    <div style="width: 600px ;margin: 0 auto">
        <div class="layui-carousel"  id="img">
            <div carousel-item >

                {if count($result.image)>0}
                    {foreach $result.image as $img}
                        <img src="__ROOT__\{$img}">
                    {/foreach}
                {/if}
            </div>
        </div>
    </div>

    <br/>
    <br/>
</body>
<script>
    layui.use('carousel', function(){
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#img',
            width: '100%',//设置容器宽度
            arrow: 'always' //始终显示箭头
            //anim: 'updown' //切换动画方式
        });
    });

</script>
<script>
    //焦点离开时触发事件
    $("input[name=number]").change(function(){
        var number  = $("input[name=number]").val();
        var id  = $("input[name=id]").val();
        var purchaseprice  = $("input[name=purchaseprice]").val();
        if(!number){
            layer.alert('数量不能为空');
            return;
        }
        if(isNaN(number)){
            layer.alert('数量必须是数字');
            return;
        }
        $.ajax({
            url:"{:url('index/purchase/updateTotal')}",
            data:"number="+number+"&id="+id+"&purchaseprice="+purchaseprice,
            type:"post",
            dataType:"json",
            success:function (data) {
                if(data.success){
                    layer.alert('修改成功',{bnt:['确定','取消']},
                        function () {
                            window.location.reload();
                        },function () {
                            window.location.reload();
                        }
                    );
                }
                if(data.error){
                    layer.alert(data.error);
                }
            }
        });
    });
</script>
</html>